package com.example.userservice.controller;


import com.example.userservice.model.User;
import com.example.userservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;


@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${spring.application.name}")
    private String appName;
    @Value("${server.port}")
    private String serverPort;

    @RequestMapping(value = "/getuser",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getUser(String name){
        return userService.getUser()+":"+appName+";port:"+serverPort+";谁调用的："+name;
    }

    @RequestMapping("/getusers")
    public List<User> getAllUsers(){
        return userService.getAllUser();
    }



}
